From: kfraser@localhost.localdomain Date: Tue, 28 Aug 2007 15:08:38 +0000 (+0100) Subject: ioemu: error checkin when setting up the Cirrus Logic video device. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14987^2~59 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=de01426fdf7361ea196626901998408b76a33735;p=xen.git ioemu: error checkin when setting up the Cirrus Logic video device. set_mm_mapping() may fail because of xc_domain_populate_physmap(). In this case, we should not blindly go on; the xc_map_foreign_batch() that follows will cause a page fault and, at best, get mapped in a zeroed page from the dom0 (which is not what we want). While I'm in here, fix a memory leak on an error path. Signed-off-by: Chris Lalancette --- diff --git a/tools/ioemu/hw/cirrus_vga.c b/tools/ioemu/hw/cirrus_vga.c index fb2f3ae556..cc73390716 100644 --- a/tools/ioemu/hw/cirrus_vga.c +++ b/tools/ioemu/hw/cirrus_vga.c @@ -2559,7 +2559,11 @@ static void *set_vram_mapping(unsigned long begin, unsigned long end) for (i = 0; i < nr_extents; i++) extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS; - set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start); + if (set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start) < 0) { + fprintf(logfile, "Failed set_mm_mapping\n"); + free(extent_start); + return NULL; + } vram_pointer = xc_map_foreign_batch(xc_handle, domid, PROT_READ|PROT_WRITE, @@ -2567,6 +2571,7 @@ static void *set_vram_mapping(unsigned long begin, unsigned long end) if (vram_pointer == NULL) { fprintf(logfile, "xc_map_foreign_batch vgaram returned error %d\n", errno); + free(extent_start); return NULL; }